package cosc617_blackteam;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;

/**
 * 
 */

/**
 * @author Laura
 *
 */
public class PercentOffTabDecorator extends SimpleTabDecorator {
	private final BigDecimal DISCOUNT_MULTIPLIER = new BigDecimal(".95");
	private final BigDecimal THRESHOLD = new BigDecimal("25");
	public PercentOffTabDecorator(I_Tab tab){
		super(tab);
	}
	public String makeRegularTab(){
		String output = "";
		final NumberFormat currencyInstance = NumberFormat.getCurrencyInstance(new Locale("en", "US"));
		if (getTabValue().compareTo(THRESHOLD) >=0 ){
			BigDecimal newTabValue = getTabValue().multiply(DISCOUNT_MULTIPLIER);
			setTabValue(newTabValue);
			output = "You have spent more than " + currencyInstance.format(THRESHOLD.doubleValue()) + 
			" so you recieve a discount! \nYour new total is:\t" + 
					currencyInstance.format(getTabValue().doubleValue()) + "\n\n";
		}
		return super.makeRegularTab() + output;
	}
}
